{% extends "tables/base_vue_table.html" %}
{% load debate_tags i18n %}

{% block head-title %}<span class="emoji">🎲</span> {% trans "Private URLs" %}{% endblock %}
{% block page-title %}{% trans "Private URLs" %}{% endblock %}

{% block page-subnav-sections %}
  {% include 'private_urls_nav.html' %}
{% endblock page-subnav-sections %}

{% block content %}

  <div class="card border-info text-info mb-3">
    <div class="card-body pb-0">
      <p>
        {% if exists %}
          {% trans "The private URLs for ballot and/or feedback submission from participants are given below." %}
        {% else %}
          {% blocktrans trimmed %}
            Private URLs are used to allow participants to submit ballots and/or
            feedback online. You should use them if you have a means of
            distributing crazy-looking URLs to participants, and are too worried
            about fraud to use a publicly accessible page where <em>anyone</em>
            can enter <em>any</em> submission. The URLs will look something like
            this:
          {% endblocktrans %}
        </p><p align="center">
          <strong><small>{% tournament_absurl 'adjfeedback-public-add-from-team-randomised' '9dnflp3z' %}</small></strong>
        </p><p>
        {% endif %}
        {% blocktrans trimmed %}
          Anyone with the URL can access the relevant data entry page. The idea is
          that it's hard to guess another key (the random-looking string), so you should
          make each URL accessible only to the participant in question.
          <a href="http://tabbycat.readthedocs.io/en/latest/features/data-entry.html#private-urls">
          Read more about private URLs.</a>
        {% endblocktrans %}
      </p>
    </div>

  </div>

  {% if pref.participant_ballots != 'private-urls' and pref.participant_feedback != 'private-urls' and not pref.public_checkins_submit %}
    <div class="card border-warning text-warning mb-3">
      <div class="card-body">
        {% tournamenturl 'options-tournament-section' section='data_entry' as data_entry_options_url %}
        {% blocktrans trimmed %}
          Neither <strong>participant ballot submissions</strong>,
          <strong>participant feedback submissions</strong>, nor <strong>participant self-checkins</strong>
          are configured to be from private URLs. Any generated URLs will not be useful unless you
          configure those settings accordingly on the
          <a href="{{ data_entry_options_url }}">tournament configuration page</a>.
        {% endblocktrans %}
      </div>
    </div>
  {% endif %}

  {% if exists %}

    {{ block.super }}

  {% else %}

    <div class="card">
      <div class="card-body">
        <div class="card-title">
          <h5>{% trans "There are no private URLs assigned." %}</h5>
        </div>
        <hr>
        <form action="{% tournamenturl 'privateurls-generate' %}" method="POST">
        {% csrf_token %}
        <button class="btn btn-success btn-block" id="generateRandomisedUrls" type="submit">
          {% trans "Generate Private URLs" %}
        </button>
        </form>
      </div>
    </div>
    <div id="vueMount"></div><!-- Must be present to prevent JS error -->

  {% endif %}

{% endblock content %}
